package comparator;

import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Person p1 = new Person("zhangsan", 20);
        Person p2 = new Person("lisi", 18);
        Person p3 = new Person("wangwu", 25);

        Person[] persons = { p1, p2, p3 };
        System.out.println("排序前");
        for (Person person : persons) {
            System.out.println(person.name + ":" + person.age);
        }

        Arrays.sort(persons, new PersonComparator());
        System.out.println("排序后");
        for (Person person : persons) {
            System.out.println(person.name + ":" + person.age);
        }
    }
}
